﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.ComponentModel;
using AutoLoL.Logic.Windows;
using System.Threading;

namespace AutoLoL.Playground
{
    /// <summary>
    /// Interaction logic for PixelChecker.xaml
    /// </summary>
    public partial class PixelChecker : Window
    {
        private BackgroundWorker _bgw;

        public PixelChecker()
        {
            InitializeComponent();

            _bgw = new BackgroundWorker();
            _bgw.WorkerReportsProgress = true;
            _bgw.ProgressChanged += new ProgressChangedEventHandler(Bgw_ProgressChanged);
            _bgw.DoWork += new DoWorkEventHandler(Bgw_DoWork);
            _bgw.RunWorkerAsync();
        }

        private void Bgw_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            bool[] r = e.UserState as bool[];
            P.Text = r[0] + Environment.NewLine + P.Text;
            C.Text = r[1] + Environment.NewLine + C.Text;
        }

        private void Bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            while (true)
            {
                List<bool> result = new List<bool>();

                using (ClientWindow win = new ClientWindow())
                {
                    result.Add(win.IsMasteriesOpen(MASTERY_WINDOWS.UserProfile));
                    result.Add(win.IsMasteriesOpen(MASTERY_WINDOWS.ChampionSelect));
                }

                _bgw.ReportProgress(0, result.ToArray());

                Thread.Sleep(500);
            }
        }
    }
}
